package com.ittest.service.store.impl;

import com.ittest.domain.store.Member;
import com.ittest.domain.store.Member;
import com.ittest.factory.MapperFactory;
import com.ittest.mapper.store.MemberMapper;
import com.ittest.service.store.MemberService;
import com.ittest.utils.TransactionUtil;
import org.apache.ibatis.session.SqlSession;

public class MemberServiceImpl implements MemberService {

    @Override
    public Member findById(String id) {
        SqlSession sqlSession = null;
        Member member = null;
        try {
            //获取sqlSession
            sqlSession = MapperFactory.getSqlSession();
            //获取Mapper代理对象
            MemberMapper memberMapper = MapperFactory.getMapper(sqlSession, MemberMapper.class);
            member = memberMapper.findById(id);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            //释放资源
            if (sqlSession!=null) {
                TransactionUtil.close(sqlSession);
            }
        }
        return member;
    }
}
